import {
  mapGetters
} from 'vuex'
export default {
  computed: {
    ...mapGetters('m_cart', ['total'])
  },
  watch: {
    total() {
      this.setBadge()
    }
  },
  methods: {

    setBadge() {
      if (this.total == 0) {
        uni.hideTabBarRedDot({
          index: 2
        })
        return
      }
      //为 tabBar 某一项的右上角添加文本。
      uni.setTabBarBadge({
        index: 2,
        text: this.total + ''
      })
    }
  },

  onShow() {
    this.setBadge()
  },
}
